<template>
    <!-- 我的收藏 -->
    <div class="box1">
        <Hand :left="true" :iconbool="false" title="我的收藏" @back="fn"></Hand>

        <div class="info">
            <MyCollectList class="list" v-for="item, index in stores.mycollect" :key="item.enshrineId"
                :title="item.gName" :num="item.storeCount" :price="item.gPrice" :discountPrice="item.discountPrice"
                @del="dels(index)" @tz="ff(item.gnId)">

                <template #img>
                    <img :src="item.photo" alt="">
                    <!-- <img src="../../img/a/u3985.png" alt=""> -->
                </template>
            </MyCollectList>
        </div>
    </div>
</template>

<script setup>
import Hand from '../../components/Hand.vue'
import MyCollectList from '../../components/MyCollectList.vue'
import { useRouter } from 'vue-router'
import { ref } from 'vue'
import { useCounterStore } from '../../stores/counter'
import { deleteC, getMyCollections } from '../../api/index'
const stores = useCounterStore()
const router = useRouter()

function fn() {
    router.back()
}

console.log(stores.mycollect);

function dels(index) {
    // NewImgArr.value.splice(index,1)
    console.log(stores.mycollect[index].enshrineId);
    deleteC(stores.mycollect[index].enshrineId).then((res) => {
        console.log(res);

        getMyCollections(localStorage.token).then((res) => {
            stores.mycollect = res.data.data.data
            // console.log(stores3.mycollect);
        })
    })

}


function ff(val) {
    console.log(111);
    router.push({
        path: 'ShopDetail',
        query: {
            id: val
        }
    })
}


</script>

<style lang="less" scoped>
.box1 {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

img {
    width: 30vw;
    height: 30vw;
}

.info {
    background: rgba(128, 128, 128, 0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    // margin-top: 9vh;
    overflow-y: scroll;

    // height: 100vh;
    .list {
        height: 30vw;
        margin: 2.667vw auto 0;
    }

    // justify-content: space-around;
}
</style>